using UnityEngine;
using System.Collections;

public class frases : MonoBehaviour 
{
	int ContadorDoPrefab;
	public Transform prefabs;
	public GameObject spritfrases;
	public Material[] imgfrase;
	int cont;
	

	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		cont++;
	
		if(cont >= 200)
		{
			spritfrases.renderer.material = imgfrase[0];
		}
		if(prefabs.position.y <= -8)
				{
					Destroy(prefabs.gameObject);
				}
		
		
	}
	
	void OnTriggerEnter(Collider other)
	{
		if(other.CompareTag("frase1"))
		{
			ContadorDoPrefab ++;
			cont = 0;
			spritfrases.renderer.material = imgfrase[1];
			if(ContadorDoPrefab <= 1)
			{
			Instantiate( prefabs, new Vector3( -25.17689f, 8.012106f, 0), Quaternion.identity);
				
			}
			
		}
		
		if(other.CompareTag("frase2"))
		{
			cont = 0;
			spritfrases.renderer.material = imgfrase[2];
		}
		
	}
}
